package com.yidu.InventoryManagement.mapper;

import com.yidu.BusinessParament.entity.Cash;
import com.yidu.InventoryManagement.entity.CashAccrualStock;
import com.yidu.InventoryManagement.entity.Fund;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * @author z
 * @version 1.0
 * @date 2022/12/8
 * 现金应收应付库存
 */
@Mapper
public interface CashAccrualStockMapper {
    /**
     * 查询
     * @param map
     * @return
     */
    @Select("select * from cashAccrualStock where 1=1 ${strWhere} limit #{page},#{limit}")
    List<CashAccrualStock> selectCashAccrualStock(Map map);
    /**
     * 分页查询
     * @param map 结果集
     * @return 根据条件查询
     */
    @Select("select count(*) from cashAccrualStock where 1=1 ${strWhere}")
    int selectCashAccrualStockInfo(Map map);

    //新增
    @Insert("INSERT INTO cashAccrualStock VALUES (#{cashAccrualStockId},#{date},#{cashId},#{businessType},#{businessState},#{money},#{initialState},#{remark})")
    public int addCashAccrualStock(CashAccrualStock accrualStock);
   //最大id
    @Select("select max(cashAccrualStockId) from cashAccrualStock")
    String getmaxcashAccrualStockId();

    @Update("update cashAccrualStock set date=#{date},cashId=#{cashId},businessType=#{businessType},businessState=#{businessState},money=#{money},remark=#{remark} where cashAccrualStockId=#{cashAccrualStockId}")
    public int updateCashAccrualStock(CashAccrualStock accrualStock);
  /* //删除
   @Delete("delete from cashAccrualStock where cashAccrualStockId=#{cashAccrualStockId}")
   int deleteCashAccrualStock(String cashAccrualStockId);
*/
    /**
     * 删除（单个删除和多个删除）
     * @param
     * @return list 集合
     */
    public int deleteCashAccrualStock(List cashAccrualStockId);


    @Select("select count(*) from cashAccrualStock")
    public int selectCashAccrualStockId();



    /**
     * 下拉表格的查询现金信息
     * @return list 集合
     */
    @Select("select * from cash where 1=1 ${term} limit #{page},#{limit};")
    public List<Cash> selectCashIdAndAccountName(Map map);

    /**
     * 下拉表格查询现金信息的行数
     */
    @Select("select count(*) from cash where 1=1 ${term}")
    public int selectCashIdAndAccountNameCount(Map map);



    /////////

    /**
     * 获得应付赎回款以及两费总和
     *
     * @param time 指定时间
     * @return double 赎回以及两费总和
     * @author 任俊杰
     */
    @Select("select sum(money) from cashAccrualStock where date = #{time} and businessType not in(3)")
    double getRedemptionOfTwoFeesSum(String time);

}
